import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
export const dayjslib = dayjs;

export function formatDateTimeCN(date = new Date()) {
  // 转成毫秒 +8 小时
  const utc = date.getTime() + date.getTimezoneOffset() * 60000; 
  const cnTime = new Date(utc + 8 * 60 * 60 * 1000); // +8 小时

  const pad = n => String(n).padStart(2, '0');
  return `${cnTime.getFullYear()}-${pad(cnTime.getMonth() + 1)}-${pad(cnTime.getDate())} ` +
         `${pad(cnTime.getHours())}:${pad(cnTime.getMinutes())}:${pad(cnTime.getSeconds())}`;
}